<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>不透明度</title>
</head>
<body>
    <canvas id="canvas"></canvas>
</body>
<script>
    let ctx = document.getElementById("canvas").getContext("2d");
    ctx.fillStyle = "red";
    ctx.globalAlpha = 50/100;
    ctx.fillRect(0,0,50,50);
    ctx.globalAlpha = 30/100;
    ctx.fillRect(25,25,50,50);
    ctx.globalAlpha = 1.0;
</script>
</html>